<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/prove_release.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    @include('UEditor::head')
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <form action="/seller/prove_release_save" method="post" id="frm-post">
            <div class="marryreal">
                <div class="name"><span class="goodsfabu">产品详情</span>
                    <div class="steps">
                        <span class="xuanz">1.选择类目</span>
                        <span class="xuanz">2.填写商品详情</span>
                        <span class="xuanzno">3.提交成功</span>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="nowxz">
                    <span>您当前选中的类目：</span>
                    <span>1</span>
                    &gt;<span>2</span>
                    &gt;<span>3</span>
                    <span class="reset"><a href="/seller/prove_release_first" rel="nofollow">(返回重选类目)</a></span>
                </div>
                <div class="name">基本信息</div>
                <div class="content" style="min-height: auto">
                    <div class="hang">
                        <div class="name"><span class="red">*</span>商品标题</div>
                        <div class="nameright">
                            <input value="{{old('name')}}" type="text" name="name" class="goodstitle" onkeyup="words_deal(this, 30);" placeholder="请填写品牌、产品名称、产品型号、产品特征及具体描述"> <span class="textCount">0</span><span>/30</span><span class="maxtitle">超过最大可输入字数</span>
                            <div class="jm_error" id="cptitle"></div>
                        </div>
                    </div>

                    <div class="hang top">
                        <div class="name">商品属性</div>
                        <div class="nameright isjiaruh">
                            <div class="rowh">
                                <div class="row_name "><span class="red">*</span>产品名称</div>
                                <div class="row_right">
                                    <input value="" type="text" name="goodsname" placeholder="请输入产品名称" class="goodsname">
                                </div>
                            </div>
                            <div class="jm_error" id="goodsname"></div>
                            <div class="rowh">
                                <div class="row_name ">自定义分类</div>
                                <div class="row_right">
                                    <input value="" type="text" name="classify" placeholder="此处将显示在店铺类目下" class="classify">
                                </div>
                            </div>
                            <div class="rowh" style="margin-bottom: 10px;">
                                <div class="row_name" ><span class="red">*</span>品牌</div>
                                <div class="row_right brandsxz" id="brands" style="margin-top: 18px;">
                                    <input type="hidden" name="brand_id" value="{{ old('brand_id') }}">
                                    <div class="qxzbrands">请选择品牌</div>
                                    <p class="jm_error fl" id="cpbrangs" style="line-height: normal;"></p>
                                    <div class="brandsxuanze">
                                        <div class="sort_box">
                                            <div class="sort_list">
                                                <div class="sort_list">
                                                    <div data-id="269" class="num_name">纽贝尔</div>
                                                </div>
                                                <div class="sort_list">
                                                    <div data-id="153" class="num_name">能富思</div>
                                                </div>
                                                <div class="sort_list">
                                                    <div data-id="263" class="num_name">奥尔威视</div>
                                                </div><div class="sort_list">
                                                    <div data-id="57" class="num_name">爱礼富</div>
                                                </div><div class="sort_list">
                                                    <div data-id="286" class="num_name">ALEPH艾礼富</div>
                                                </div><div class="sort_list">
                                                    <div data-id="76" class="num_name">奥芯电子</div>
                                                </div><div class="sort_list">
                                                    <div data-id="222" class="num_name">奥达科技</div>
                                                </div><div class="sort_list">
                                                    <div data-id="317" class="num_name">爱普生EPSON</div>
                                                </div><div class="sort_list">
                                                    <div data-id="390" class="num_name">automatic systems</div>
                                                </div><div class="sort_list">
                                                    <div data-id="290" class="num_name">ANENC安耐克</div>
                                                </div><div class="sort_list">
                                                    <div data-id="300" class="num_name">安尔</div>
                                                </div><div class="sort_list">
                                                    <div data-id="196" class="num_name">安锐通科技</div>
                                                </div><div class="sort_list">
                                                    <div data-id="358" class="num_name">安达通ADT</div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="rowh">
                                <div class="row_name "><span class="red">*</span>型号</div>
                                <div class="row_right">
                                    <input value="{{ old('model') }}" type="text" name="model" placeholder="请输入产品型号" class="xinghao">
                                </div>
                            </div>
                            <div class="jm_error fl" style="" id="cpxinghao"></div>
                            <div class="rowh">
                                <div class="row_name">关键词</div>
                                <div class="row_right keyword_box">
                                    <ul class="fl">
                                        <li><input value="" type="text" name="keyword[]" class="fl keyword"></li>
                                    </ul>
                                    <sapn class="bnt_keyword">+添加属性</sapn>
                                    <font>如果我们提供的产品属性无法满足你的需求，你可以自定义最多3个产品属性信息</font>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="content" style="min-height: auto">
                    <div class="hang">
                        <div class="name namefilee" ><span class="red">*</span>列表图</div>
                        <div class="nameright">
                            <div class="modify fl fontsize" >
                                <div class="imgbox">
                                    <div class="list_image fl"></div>
                                    <img src="{{asset('/img/web/user/file.png')}}" title="点此上传商品图片" class="btn_listimg" style="cursor: pointer;" data-id="0"/>
                                </div>
                            </div>
                        </div>
                        <div class="jm_error fl" id="err_listimg"></div>
                    </div>
                    <div class="hang top">
                        <div class="name namefilee" ><span class="red">*</span>主图(详情页)</div>
                        <div class="nameright">
                            <div class="modify fl fontsize" >
                                <div class="imgbox">
                                    <img src="{{asset('/img/web/user/file.png')}}" title="点此上传商品图片" class="shangchuan btn_detailimg" style="cursor: pointer;" id="upload-img" data-id="1"/>
                                </div>
                            </div>
                        </div>
                        <div class="jm_error fl" id="err_image"></div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>商品详情</div>
                        <div class="nameright">
                            <script id="editor_id" name="product_detail"  style="min-height:300px;" type="text/plain"> {!! old('product_detail') !!} </script>
                            <div class="jm_error fl" id="err_content"></div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>产地</div>
                        <div class="nameright2">
                            <div class="namedt" style="position: relative;">
                                <input value="" type="text" name="placeOrigin" class="minorder placeOrigin" id="selected_city" name="placeOrigin" autocomplete="off" data-region-id="">
                                @include('web.layout.city_placeOrigint')
                            </div>
                            <div class="jm_error fl" id="err_placeOrigin"></div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>计量单位</div>
                        <div class="nameright">
                            <div class="namedt unitlist">
                                <label><input checked="checked" class="unit" type="radio" name="unit" value="1"/>个</label>
                                <label><input class="unit" type="radio" name="unit" value="2"/>台</label>
                                <label><input class="unit" type="radio" name="unit" value="3"/>件</label>
                                <label><input class="unit" type="radio" name="unit" value="4"/>箱</label>
                                <label><input class="unit" type="radio" name="unit" value="5"/>米</label>
                            </div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>发货周期</div>
                        <div class="nameright">
                            <div class="namedt">
                                <select class="deliveryCycle">
                                    <option value="1">3-5个工作日</option>
                                    <option value="2">6-9个工作日</option>
                                    <option value="3">10-15个工作日</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>保质期</div>
                        <div class="nameright">
                            <div class="namedt">
                                <select class="keepTime">
                                    <option value="1">1年</option>
                                    <option value="2">2年</option>
                                    <option value="3">3年</option>、
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>是否优惠促销</div>
                        <div class="nameright">
                            <div class="namedt promotionlist">
                                <label><input class="promotion" checked="checked" type="radio" name="promotion" value="1"/>是</label>
                                <label><input class="promotion" type="radio" name="promotion" value="0"/>否</label>
                            </div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>是否推荐</div>
                        <div class="nameright">
                            <div class="namedt recommendlist">
                                <label><input class="recommend" checked="checked" type="radio" name="recommend" value="1"/>是</label>
                                <label><input class="recommend" type="radio" name="recommend" value="0"/>否</label>
                            </div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name"><span class="red">*</span>是否热门产品</div>
                        <div class="nameright">
                            <div class="namedt hotlist">
                                <label><input class="hot" checked="checked" type="radio" name="hot" value="1"/>是</label>
                                <label><input class="hot" type="radio" name="hot" value="0"/>否</label>
                            </div>
                        </div>
                    </div>

                    <div class="hang top">
                        <div class="name"><span class="red">*</span>商品规格</div>
                        <div class="skuright">
                            <ul class="SKU_TYPE">
                                <li is_required='0' propid='1' sku-type-name="存储">存储：</li>
                            </ul>
                            <ul class="sku_value_ul">
                                <li><label><input type="checkbox" class="sku_value" propvalid='11' propid='1' value="16G" />16G</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='12' propid='1' value="32G" />32G</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='13' propid='1' value="64G" />64G</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='14' propid='1' value="128G" />128G</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='15' propid='1' value="256G" />256G</label></li>
                            </ul>
                            <div class="clear"></div>
                            <ul class="SKU_TYPE">
                                <li is_required='0' propid='2' sku-type-name="版本">版本：</li>
                            </ul>
                            <ul class="sku_value_ul">
                                <li><label><input type="checkbox" class="sku_value" propvalid='21' propid='2' value="中国大陆版" />中国大陆版</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='22' propid='2' value="港版" />港版</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='23' propid='2' value="韩版" />韩版</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='24' propid='2' value="美版" />美版</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='25' propid='2' value="日版" />日版</label></li>
                            </ul>
                            <div class="clear"></div>

                            <ul class="SKU_TYPE">
                                <li is_required='0' propid='3' sku-type-name="颜色">颜色：</li>
                            </ul>
                            <ul class="sku_value_ul">
                                <li><label><input type="checkbox" class="sku_value" propvalid='31' propid='3' value="土豪金" />土豪金</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='32' propid='3' value="银白色" />银白色</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='33' propid='3' value="深空灰" />深空灰</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='34' propid='3' value="黑色" />黑色</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='33' propid='3' value="玫瑰金" />玫瑰金</label></li>
                            </ul>
                            <div class="clear"></div>
                            <ul class="SKU_TYPE">
                                <li is_required='0' propid='4' sku-type-name="类型">类型：</li>
                            </ul>
                            <ul class="sku_value_ul">
                                <li><label><input type="checkbox" class="sku_value" propvalid='41' propid='4' value="儿童" />儿童</label></li>
                                <li><label><input type="checkbox" class="sku_value" propvalid='42' propid='4' value="成人" />成人</label></li>
                            </ul>
                            <div class="clear"></div>
                            <div id="skuTable"></div>
                            <div class="jm_error fl" id="err_sku"></div>
                        </div>
                    </div>
                    <div class="hang top">
                        <div class="name">售后服务</div>
                        <div class="nameright">
                            <div class="namedt servicelist">
                                <label><input class="service" type="checkbox" name="service" value="1"/>提供发票</label>
                                <label><input class="service" type="checkbox" name="service" value="2"/>保修服务</label>
                                <label><input class="service" type="checkbox" name="service" value="3"/>退货承诺：诺存在质量问题或与描述不符，本店将主动提供退货服务并承担来回邮费</label>
                                <input type="hidden" name="afterservice" value="">
                            </div>
                        </div>
                    </div>
                    <!-- <div class="hang top">
                        <div class="name"><span class="red">*</span>运费</div>
                        <div class="nameright">
                            <div class="namedt">
                                <select class="freightSelect">
                                    <option value="1">固定运费</option>
                                </select>
                                <input type="text" name="freight" class="freight" value="">
                                <span>元</span>
                            </div>
                            <div class="jm_error fl" id="err_freight"></div>
                        </div>
                    </div> -->
                    <div class="hang top">
                        <div class="name">橱窗推荐</div>
                        <div class="nameright">
                            <div class="namedt windowlist">
                                <label><input class="window" type="checkbox" name="window" value="1"/>是</label>
                                <span>您的橱窗使用情况：共<font>【15】</font>个，已用【2】个。</span>
                            </div>
                        </div>
                    </div>
                </div>
                {{csrf_field()}}
                <input name="category_name" value="1" type="hidden">
                <input type="hidden" id="submit_type" name="submit_type" value="0">
                <input type="hidden" name="categorys" value="1">
                <input type="hidden" name="lib_product_id" value="0">
                <input type="button" data-type="1" class="drafts" value="保存至草稿箱">
                <input type="button" data-type="0" class="tijiao" value="发布产品">
            </div>
            </form>
        </div>
    </div>
</div>
<form id="uploadForm" action="{{url('uploads/images')}}" method="post">
    {{csrf_field()}}
    <input style="display: none;" name="image" type="file" class="inputFile" />
</form>
@include('web.layout.footer')
<script src="{{mix('/js/web/image/uploadPreview.min.js')}}"></script>
<script src="{{mix('/js/web/user/jquery.charfirst.pinyin.js')}}"></script>
<script src="{{mix('/js/web/user/sort.js')}}"></script>
<script type="text/javascript">
    // 增加商品属性的js
    $(function () {
        // Stuff to do as soon as the DOM is ready;
        $(document).on("click", ".addrow", function () {
            var addcolumn = "<div class='rowh'><div class='row_name'><input type='text' name='' placeholder='请输入属性名'></div><div class='row_right'><input type='text' name='' placeholder='请输入属性值'></div></div>";
            $(".isjiaruh").append(addcolumn);
            $(".rowh").each(function () {
                if ($(".rowh").length > 10) {
                    $(".addrow").attr("disabled", true);
                    return false;
                }
            });
        });

        // 品牌选择 下拉选择框 根据拼音进行排序
        $(".qxzbrands").click(function () {
            $(".brandsxuanze").show();
        });
        $(".num_name").click(function () {
            var $this = $(this);
            $(".qxzbrands")[0].innerText = $this.text();
            $('#brands').find('input[name="brand_id"]').val($this.data('id'));
            $(".brandsxuanze").hide();
        });

        //关键词
        $(".bnt_keyword").click(function () {
            if($('.keyword_box ul li').length >= 3){
                layer.alert('最多增加3个产品属性信息', {
                    title:'提示',
                    icon: 2
                });
            }else{
                $('.keyword_box ul').append('<li><input value="" type="text" name="keyword[]" class="fl keyword"></li>')
            }
            var $this = $(this);
            $(".qxzbrands")[0].innerText = $this.text();
            $('#brands').find('input[name="brand_id"]').val($this.data('id'));
            $(".brandsxuanze").hide();
        });

        $(".tijiao, .drafts").click(function () {

            getAlreadySetSkuVals()
            if($(".goodstitle").val()==''){
                $("#cptitle").html("请填写产品标题");
                return false;
            }else {
                $("#cptitle").html("");
            }
            if($(".goodsname").val()==''){
                $("#err_goodsname").html("请填写产品名称");
                return false;
            }else {
                $("#err_goodsname").html("");
            }
            if($(".qxzbrands").text()=="请选择品牌") {
                $("#cpbrangs").html("请选择品牌");
                return false;
            }else{
                $("#cpbrangs").html("");
            }
            if($(".xinghao").val()=="") {
                $("#cpxinghao").html("请填写产品型号");
                return false;
            }else{
                $("#cpxinghao").html("");
            }
            if (!$('input[name="listimage"]').val()){
                $("#err_listimg").html('请上传列表图');
                return false;
            } else {
                $("#err_listimg").html('');
            }
            if ($('.shangchuan').length <= 1){
                $("#err_image").html('请上传主图(详情页)');
                return false;
            } else {
                $("#err_image").html('');
            }
            if (ue_detail.getContent() ==''){
                $("#err_content").html('请填写商品详情信息');
                return false;
            } else {
                $("#err_content").html('');
            }
            if ($('input[name="placeOrigin"]').val() == '' || $('input[name="placeOrigin"]').val() == '选择产地'){
                $("#err_placeOrigin").html('请选择产地');
                return false;
            } else {
                $("#err_placeOrigin").html('');
            }
            var sku_input_num = 0;
            $('.skuTable input[type="text"]').each(function(){
                if($(this).val == ''){
                    sku_input_num++;
                }
            })
            if (sku_input_num > 0 || $('.skuTable input[type="text"]').length  == 0){
                $("#err_sku").html('请填写商品规格');
                return false;
            } else {
                $("#err_sku").html('');
            }
            /*if ($('input[name="freight"]').val() == ''){
                $("#err_freight").html('请填写运费');
                return false;
            } else {
                $("#err_freight").html('');
            }*/
            $('#submit_type').val($(this).data('type'));
            $('#frm-post').submit();
        });
        var img_type;
        // 图片上传点击
        $('.btn_listimg, .btn_detailimg').click(function () {
            img_type = $(this).attr('data-id');
            if(img_type == 1){
                var _length = $(this).parent().find('.shangchuan').length
                if (_length < 6) {
                    $('.inputFile').trigger('click');
                } else {
                    layer.alert('最多可上传五张商品图', {
                        title:'提示',
                        icon: 2
                    });
                }
            }else{
                $('.inputFile').trigger('click');
            }
        });
        $(document).on('mouseover', '.upload-img-item', function () {
            var $this = $(this);
            $this.find('.icon-colse').show();
        }).on('mouseout', '.upload-img-item', function () {
            var $this = $(this);
            $this.find('.icon-colse').hide();
        });
        $(document).on('click', '.icon-colse', function () {
            var $this = $(this), img_name = $this.parent().find('.shangchuan').attr('src');
            $("#frm-post").find('input[class="j-hid-images"]').each(function () {
                if (img_name == $(this).val()){
                    $(this).remove();
                }
            });
            $this.parent().remove();
        });
        // 选择完要上传的文件后, 直接触发表单提交
        $('input[name=image]').on('change', function () {
            if ($.trim($(this).val())) {
                $("#uploadForm").trigger('submit');
            }
        });

        // 图片上传
        $("#uploadForm").on('submit', function (e) {
            e.preventDefault();
            $.ajax({
                url: "{{url('uploads/images')}}",
                type: "POST",
                data: new FormData(this),
                contentType: false,
                cache: false,
                processData: false,
                // 显示加载图片
                success: function (res) {
                    if (res.status == 0){
                        var img_path = '' + res.path;
                        if(img_type == 0){
                            var html = '<div class="upload-img-item"><img src="'+ img_path +'" class="shangchuan" /></div><input type="hidden" name="listimage" value="'+ img_path +'"/>';
                            $(".list_image").html(html);
                        }else{
                            $("#upload-img").parent().prepend('<div class="upload-img-item"><img src="/img/web/user/close.png" class="icon-colse" /><img src="'+ img_path +'" class="shangchuan" /></div>');
                            $("#frm-post").append('<input type="hidden" name="image[]" value="'+ img_path +'" class="j-hid-images"/>');
                        }
                    } else {
                        layer.alert('图片上传失败', {
                            title:'提示',
                            icon: 2
                        });
                    }
                },
                error: function () { }
            });
        });

    });

    // 限制输入长度
    function words_deal(obj, len) {
        var $this = $(obj);
        var curLength = $this.val().length;
        if (curLength > len) {
            var num = $this.val().substr(0, len);
            $this.val(num);
            $this.parent().find(".maxtitle").show();
        } else {
            $this.parent().find(".textCount").text(len - $this.val().length);
            $this.parent().find(".maxtitle").hide();
        }
    }

    var ue_detail = UE.getEditor('editor_id', { initialFrameWidth: null });
    ue_detail.ready(function() {
        ue_detail.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
    });


//获取已经设置的SKU
$(".getSetSkuVal").on("click",function(){
    $("tr[class*='sku_table_tr']").each(function(){
        var propids = $(this).attr("propids");//SKU类型主键
        var propvalids = $(this).attr("propvalids");//SKU值主键


    });
});


//售后服务
$(".service").on("click",function(){
    var service ='';
    $(".service").each(function(){
        if($(this).is(':checked')){
            service= service +$(this).val() + ',';
        }
    });
    service = service.substring(0,service.length -1);
    $('input[name="afterservice"]').val(service);
});

var alreadySetSkuVals = {};//已经设置的SKU值数据

$(function(){
    //sku属性发生改变时,进行表格创建
    $(document).on("change",'.sku_value',function(){
        getAlreadySetSkuVals();//获取已经设置的SKU值
        console.log(alreadySetSkuVals);
        var b = true;
        var skuTypeArr =  [];//存放SKU类型的数组
        var totalRow = 1;//总行数
        //获取元素类型
        $(".SKU_TYPE").each(function(){
            //SKU类型节点
            var skuTypeNode = $(this).children("li");
            var skuTypeObj = {};//sku类型对象
            //SKU属性类型标题
            skuTypeObj.skuTypeTitle = $(skuTypeNode).attr("sku-type-name");
            //SKU属性类型主键
            var propid = $(skuTypeNode).attr("propid");
            skuTypeObj.skuTypeKey = propid;
            //是否是必选SKU 0：不是；1：是；
            var is_required = $(skuTypeNode).attr("is_required");
            skuValueArr = [];//存放SKU值得数组
            //SKU相对应的节点
            var skuValNode = $(this).next();
            //获取SKU值
            var skuValCheckBoxs = $(skuValNode).find("input[type='checkbox'][class*='sku_value']");
            var checkedNodeLen = 0 ;//选中的SKU节点的个数
            $(skuValCheckBoxs).each(function(){
                if($(this).is(":checked")){
                    var skuValObj = {};//SKU值对象
                    skuValObj.skuValueTitle = $(this).val();//SKU值名称
                    skuValObj.skuValueId = $(this).attr("propvalid");//SKU值主键
                    skuValObj.skuPropId = $(this).attr("propid");//SKU类型主键
                    skuValueArr.push(skuValObj);
                    checkedNodeLen ++ ;
                }
            });
            if(is_required && "1" == is_required){//必选sku
                if(checkedNodeLen <= 0){//有必选的SKU仍然没有选中
                    b = false;
                    return false;//直接返回
                }
            }
            if(skuValueArr && skuValueArr.length > 0){
                totalRow = totalRow * skuValueArr.length;
                skuTypeObj.skuValues = skuValueArr;//sku值数组
                skuTypeObj.skuValueLen = skuValueArr.length;//sku值长度
                skuTypeArr.push(skuTypeObj);//保存进数组中
            }
        });
        var SKUTableDom = "";//sku表格数据
        //开始创建行
        if(b){//必选的SKU属性已经都选中了

//          //调整顺序(少的在前面,多的在后面)
//          skuTypeArr.sort(function(skuType1,skuType2){
//              return (skuType1.skuValueLen - skuType2.skuValueLen)
//          });
//

            if(skuTypeArr.length == 0){
                $("#skuTable").html('');
                return false;
            }
            SKUTableDom += "<table class='skuTable'><tr>";
            //创建表头
            for(var t = 0 ; t < skuTypeArr.length ; t ++){
                SKUTableDom += '<th>'+skuTypeArr[t].skuTypeTitle+'</th>';
            }
            SKUTableDom += '<th width ="70">价格(元)</th><th width ="70">促销价(元)</th><th width ="70">库存数</th><th width ="150">商家编码</th><th width ="70">运费</th>';
            SKUTableDom += "</tr>";
            //循环处理表体
            for(var i = 0 ; i < totalRow ; i ++){//总共需要创建多少行
                var currRowDoms = "";
                var rowCount = 1;//记录行数
                var propvalidArr = [];//记录SKU值主键
                var propIdArr = [];//属性类型主键
                var propvalnameArr = [];//记录SKU值标题
                var propNameArr = [];//属性类型标题
                for(var j = 0 ; j < skuTypeArr.length ; j ++){//sku列
                    var skuValues = skuTypeArr[j].skuValues;//SKU值数组
                    var skuValueLen = skuValues.length;//sku值长度
                    rowCount = (rowCount * skuValueLen);//目前的生成的总行数
                    var anInterBankNum = (totalRow / rowCount);//跨行数
                    var point = ((i / anInterBankNum) % skuValueLen);
                    propNameArr.push(skuTypeArr[j].skuTypeTitle);
                    if(0  == (i % anInterBankNum)){//需要创建td
                        currRowDoms += '<td rowspan='+anInterBankNum+'>'+skuValues[point].skuValueTitle+'</td>';
                        propvalidArr.push(skuValues[point].skuValueId);
                        propIdArr.push(skuValues[point].skuPropId);
                        propvalnameArr.push(skuValues[point].skuValueTitle);
                    }else{
                        //当前单元格为跨行
                        propvalidArr.push(skuValues[parseInt(point)].skuValueId);
                        propIdArr.push(skuValues[parseInt(point)].skuPropId);
                        propvalnameArr.push(skuValues[parseInt(point)].skuValueTitle);
                    }
                }
//
//              //进行排序(主键小的在前,大的在后),注意:适用于数值类型的主键
//              propvalidArr.sort(function(provids1,propvids2){
//                  return (provids1 - propvids2)
//              });

                var propvalids = propvalidArr.toString();
                //console.log('propvalids',propvalids)
                var alreadySetSkuPrice = "";//已经设置的SKU价格
                var alreadySetSkuStock = "";//已经设置的SKU库存
                //赋值
                /*if(alreadySetSkuVals){
                    var currGroupSkuVal = alreadySetSkuVals[propvalids];//当前这组SKU值
                    if(currGroupSkuVal){
                        alreadySetSkuPrice = currGroupSkuVal.skuPrice;
                        alreadySetSkuStock = currGroupSkuVal.skuStock
                    }
                }*/
                //console.log(propvalids);
                SKUTableDom += '<tr propvalids=\''+propvalids+'\' propids=\''+propIdArr.toString()+'\' propvalnames=\''+propvalnameArr.join(";")+'\'  propnames=\''+propNameArr.join(";")+'\' class="sku_table_tr">'+currRowDoms+'<td><input type="text" class="setting_sku_price" value=""/></td><td><input type="text" class="setting_sku_originalprice" value=""/></td><td><input type="text" class="setting_sku_stock" value=""/></td><td><input type="text" class="setting_sku_coding" value=""/></td><td><input type="text" class="setting_sku_freight" value=""/></td></tr>';
            }
            SKUTableDom += "</table>";
        }
        $("#skuTable").html(SKUTableDom);
    });
});

/**
 * 获取已经设置的SKU值
 */
function getAlreadySetSkuVals(){
    alreadySetSkuVals = {};
    //获取设置的SKU属性值
    $("tr[class*='sku_table_tr']").each(function(){
        var skuPrice = $(this).find("input[type='text'][class*='setting_sku_price']").val();//SKU价格
        var skuOriginalprice = $(this).find("input[type='text'][class*='setting_sku_originalprice']").val();//促销价价格
        var skuStock = $(this).find("input[type='text'][class*='setting_sku_stock']").val();//SKU库存
        var skuCoding = $(this).find("input[type='text'][class*='setting_sku_coding']").val();//SKU商家编码
        var skuFreight = $(this).find("input[type='text'][class*='setting_sku_freight']").val();//SKU运费
        var attributes = '';
        if(skuPrice || skuStock){//已经设置了全部或部分值
            var propvalids = $(this).attr("propvalids");//SKU值主键集合
            var propids = $(this).attr("propids");
            var propvalid = propvalids.split(',');
            var propid = propids.split(',');

            for(var i = 0;i<propvalid.length;i++){
                attributes += propid[i]+','+propvalid[i]+';'
            }
            attributes = attributes.substring(0, attributes.length -1);
            //console.log('attributes',attributes)\
            alreadySetSkuVals[propvalids] = {
                'attributes':attributes,
                "price" : skuPrice,
                "sale_price" : skuOriginalprice,
                "stock" : skuStock,
                "seller_code" : skuCoding,
                "freight" : skuFreight

            }
        }
    });
    alreadySetSkuVals = JSON.stringify(alreadySetSkuVals);
    //console.log('11',alreadySetSkuVals)
}
</script>
</body>


</html>